using System;
using System.Xml.Serialization;
using RTMBindings.Model;
using System.Windows.Input;

namespace RTMBindings.Responses
{
    public class RTMTask
    {
        [XmlAttribute("id")]
        public int Id { get; set; }

        [XmlAttribute("due")]
        public string DueString { get; set; }

        [XmlIgnore]
        public DateTime? Due
        {
            get
            {
                if (string.IsNullOrEmpty(DueString))
                    return null;
                return DateTime.Parse(DueString);
            }
        }

        [XmlAttribute("has_due_time")]
        public bool HasDueTime { get; set; }

        [XmlAttribute("added")]
        public DateTime Added { get; set; }

        [XmlAttribute("completed")]
        public string CompletedString { get; set; }

        [XmlIgnore]
        public DateTime? Completed
        {
            get
            {
                if (string.IsNullOrEmpty(CompletedString))
                    return null;
                else
                    return DateTime.Parse(CompletedString);
            }
        }

        [XmlAttribute("deleted")]
        public string DeletedString { get; set; }

        [XmlIgnore]
        public DateTime? Deleted
        {
            get
            {
                if (string.IsNullOrEmpty(DeletedString))
                    return null;
                else
                    return DateTime.Parse(DeletedString);
            }
        }


        [XmlAttribute("priority")]
        public RTMPriority Priority { get; set; }

        [XmlAttribute("postponed")]
        public int? Postponed { get; set; }

        [XmlAttribute("estimate")]
        public string Estimate { get; set; }
    }
}